<?php
/**
 * Created by PhpStorm.
 * User: Tom
 * Date: 2018/7/7
 * Time: 15:07
 */

namespace app\tph\controller;

error_reporting(E_ERROR);


class Createm extends base
{
    public function index()
    {
        $request = request();
        $moudulename=$request->module();

        $this->assign("moudulename",$moudulename);
        $this->assign("db_prefix",config("database.prefix"));

        $tableNameList = getTableNameList();
        $this->assign('tableNameList', $tableNameList);
        $moduleNameList = getModuleNameList();
        $this->assign('moduleNameList', $moduleNameList);
        $layoutNameList = $this->getLayoutTemplateNameList();
        $this->assign('layoutNameList', $layoutNameList);
        $this->assign('selectTableName', $this->getSessionTableName());
        $this->assign("table","user");


        return $this->fetch();
    }

    public function getSessionTableName(){
        //$selectTableName = implode("','", session('selectTableName'));
        if (input('session.selectTableName/d'))
        {
            $selectTableName = implode("','", input('session.selectTableName/d'));
            return "['".$selectTableName."']";
        }
        return "[]";

    }

    public function getLayoutTemplateNameList(){
        $layoutTemplateNameList0 = FileUtil::getDirList(ROOT_PATH. "public/template");
        $layoutTemplateNameList = array();
        foreach($layoutTemplateNameList0 as $layoutDirName){
            if(substr($layoutDirName, -6) == 'layout'){	//判断以layout结尾的才是布局文件夹
                $layoutTemplateNameList[] = $layoutDirName;
            }
        }
        return $layoutTemplateNameList;
    }
}